<?php

/**
 * @author yupoxiong<i@yufuping.com>
 */

namespace generate\field;

class Text extends Field
{

    public static $html = <<<EOF
<div class="layui-form-item">
    <label for="[FIELD_NAME]" class="layui-form-label  [REQUIRED]">[FORM_NAME]</label>
    <div class="layui-input-block">
        <input id="[FIELD_NAME]" name="[FIELD_NAME]" lay-verify="[FORM_VALIDATE]" autocomplete="off"  value="{\$data.[FIELD_NAME]|default='[FIELD_DEFAULT]'}" placeholder="请输入[FORM_NAME]" type="text"   class="layui-input" >
    </div>
</div>\n
EOF;

    public static $rules = [
        'required'   => '非空',
        'account'    => '账号',
        'cn_name'    => '中文姓名',
        'regular'    => '自定义正则'
    ];

    public static function create($data)
    {
        
        self::getValidateHtml($data['form_validate']);
        return  str_replace(
            array('[FORM_NAME]', '[FIELD_NAME]', '[FIELD_DEFAULT]', '[FORM_VALIDATE]', '[REQUIRED]'),
            array($data['form_name'], $data['field_name'], $data['field_default'], self::$verify, self::$required),
            self::$html
        );
    }
}
